package com.boot2.controller.req;

import com.boot2.pojo.User;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;
import java.time.LocalDateTime;
import java.util.Arrays;
import java.util.List;

/**
 * @author wzm
 * @create 2023-11-29 10:09
 * project_name:web2310
 * @Description
 */
@RestController //控制器
public class RequestController1 {
    //接收处理日期时间参数
    @RequestMapping("/dateParam")
    public String dataParam(@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime updateTime){
        System.out.println("updateTime = " + updateTime);
        return "ok";
    }

    //接收jons数据
    @RequestMapping("/jsonParam")
    public String jsonParam(@RequestBody User user){
        System.out.println("user = " + user);
        return "ok";
    }

    //接收路径参数
/*    @RequestMapping("/path/{id}")
    public String path(@PathVariable Integer id){
        System.out.println("id = " + id);
        return "ok";
    }*/

    //模拟了分页是需要传入当前页和显示每页几条数据
    @RequestMapping("/path/{page}/{size}")
    public String path(@PathVariable("page") Integer currentPage, @PathVariable("size") Integer pageSize){
        System.out.println("currentPage = " + currentPage);
        System.out.println("pageSize = " + pageSize);
        return "ok";
    }

}
